package cn.train.controler;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


import cn.train.model.UserTable;
import cn.train.service.VipCoderAndPassServices;

@WebServlet("/VipPassServlet")
public class VipPassServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String pass=req.getParameter("pass");
		HttpSession session=req.getSession();
		UserTable use=(UserTable)session.getAttribute("usertable");	
		int id=use.getUid();
		VipCoderAndPassServices vaps=new VipCoderAndPassServices();
		int m=vaps.update(pass, id);
		PrintWriter out=resp.getWriter();
		if(m>0){
			out.print("<script>alert('修改成功，请重新登录');parent.location.href='font/login.jsp'</script>");
		}else{
			out.print("<script>alert('修改失败，请重新登录');</script>");
		}
	}
	
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
		doGet(req, resp);
	}
}	
